// import Layout from '@/views/layout/Layout'

const routerUtils = function(data) {
  console.log('----------------------------------------------------------')
  console.log(processRouterInfo(data))
  return processRouterInfo(data)
}

function processRouterInfo(data) {
  var router = {}
  if (data) {
    if (data.name) {
      router.meta = { title: data.name, icon: 'table' }
    }

    if (data.path) {
      router.path = data.path
      router.component = () => import(`@/views${data.path}/index`)
    }

    if (data.children && data.children.length > 0) {
      for (var i = 0; i < data.children.length; i++) {
        data.children[i] = processRouterInfo(data.children[i])
      }
    }
  }

  return router
}

export default routerUtils
